﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sharp.DataTransferObject;
using Sharp.Infrastructure.Communication;
using Sharp.ServiceContracts;

namespace Sharp.Platform
{
    public class Platform
    {
        public static void InitPortal()
        {

        }

        private static readonly object LockHelper = new object();
        private static List<PermissionDTO> _permissions;

        public static  IList<PermissionDTO> AllPermission()
        {
            lock (LockHelper)
            {
                if (_permissions == null)
                {
                    lock (LockHelper)
                    {

                        using (var proxy = new ServiceProxy<IUserService>())
                        {
                            _permissions = proxy.Channel.AllPermissions().ToList();
                        }

                    }
                }

                return _permissions;

            }
        }
    }
}